﻿<Window x:Class="SilverlightInjector.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:si="clr-namespace:SilverlightInjector"
        MouseDown="Window_MouseDown"
        WindowStyle="None"
        ResizeMode="NoResize"
        AllowsTransparency="True"
        Topmost="True"
        Icon="App.ico"
        Background="Transparent"
        Title="Silverlight Snoop"
        Height="32"
        Width="320">
    <Window.Resources>
        <LinearGradientBrush x:Key="BlueGlassGradient"
                             EndPoint="0.5,1"
                             StartPoint="0.5,0">
            <GradientStop Color="#FF0052D7"
                          Offset="0" />
            <GradientStop Color="#FF3D86FD"
                          Offset="1" />
            <GradientStop Color="#FF003B9F"
                          Offset="0.472" />
            <GradientStop Color="#FF4080ED"
                          Offset="0.648" />
        </LinearGradientBrush>

        <DrawingBrush x:Key="Search"
                      Stretch="Uniform">
            <DrawingBrush.Drawing>
                <DrawingGroup>
                    <GeometryDrawing Brush="#80CDEBFB"
                                     Geometry="F1 M 7.94234,3.21968C 9.2723,4.54858 9.2723,6.70461 7.94234,8.03351C 6.61344,9.36241 4.45741,9.36241 3.12746,8.03351C 1.79856,6.70461 1.79856,4.54858 3.12746,3.21968C 4.45741,1.89078 6.61344,1.89078 7.94234,3.21968 Z ">
                        <GeometryDrawing.Pen>
                            <Pen Thickness="0.333333"
                                 LineJoin="Round"
                                 Brush="#80A7A9AC" />
                        </GeometryDrawing.Pen>
                    </GeometryDrawing>
                    <GeometryDrawing Geometry="F1 M 2.18561,2.27751C 0.336979,4.1272 0.336979,7.1262 2.18561,8.97483L 2.18561,8.97483C 4.03529,10.8245 7.0343,10.8245 8.88504,8.97483L 8.88504,8.97483C 10.7337,7.1262 10.7337,4.1272 8.88504,2.27751L 8.88504,2.27751C 7.95967,1.3532 6.74697,0.890512 5.53532,0.890512L 5.53532,0.890512C 4.32262,0.890512 3.11098,1.3532 2.18561,2.27751 Z M 3.23352,7.93009C 1.96166,6.65612 1.96166,4.59516 3.23352,3.32436L 3.23352,3.32436C 4.50326,2.05356 6.56527,2.05356 7.83819,3.32436L 7.83819,3.32436C 9.10899,4.59516 9.10899,6.65612 7.83819,7.93009L 7.83819,7.93009C 7.20226,8.56496 6.36773,8.88187 5.53532,8.88187L 5.53532,8.88187C 4.70186,8.88187 3.86839,8.56496 3.23352,7.93009 Z ">
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="-0.0862707,-0.0862862"
                                                 EndPoint="2.15683,2.157">
                                <GradientStop Color="#FFFFFFFF"
                                              Offset="0" />
                                <GradientStop Color="#FFFFFFFF"
                                              Offset="0.126373" />
                                <GradientStop Color="#FF57585A"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <DrawingGroup ClipGeometry="F1 M 0,0L 15.8454,0L 15.8454,15.8454L 0,15.8454L 0,0 Z ">
                        <GeometryDrawing Geometry="F1 M 7.83755,7.92935C 6.5657,9.20015 4.50368,9.20015 3.23288,7.92935C 1.96103,6.65644 1.96103,4.59548 3.23288,3.32468C 4.50368,2.05282 6.5657,2.05282 7.83755,3.32468C 9.10941,4.59548 9.10941,6.65644 7.83755,7.92935 Z M 8.88441,2.27783C 7.03472,0.428143 4.03572,0.428143 2.18603,2.27783C 0.336345,4.12646 0.336345,7.12652 2.18603,8.97515C 4.03572,10.8248 7.03472,10.8248 8.88441,8.97515C 10.7341,7.12652 10.7341,4.12646 8.88441,2.27783 Z ">
                            <GeometryDrawing.Pen>
                                <Pen Thickness="0.666667"
                                     LineJoin="Round"
                                     Brush="#FF848688" />
                            </GeometryDrawing.Pen>
                        </GeometryDrawing>
                    </DrawingGroup>
                    <GeometryDrawing Geometry="F1 M 8.09911,8.92307L 9.92978,10.7537L 10.7675,9.9171L 8.9368,8.08432L 8.09911,8.92307 Z ">
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="0.185953,0.81438"
                                                 EndPoint="0.990913,0.81438">
                                <LinearGradientBrush.RelativeTransform>
                                    <TransformGroup>
                                        <SkewTransform CenterX="0.185953"
                                                       CenterY="0.81438"
                                                       AngleX="0.0226327"
                                                       AngleY="0" />
                                        <RotateTransform CenterX="0.185953"
                                                         CenterY="0.81438"
                                                         Angle="-44.9887" />
                                    </TransformGroup>
                                </LinearGradientBrush.RelativeTransform>
                                <GradientStop Color="#FFFFFFFF"
                                              Offset="0" />
                                <GradientStop Color="#FFFFFFFF"
                                              Offset="0.0549469" />
                                <GradientStop Color="#FF57585A"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing Geometry="F1 M 2.24793,2.33984C 0.432051,4.15466 0.432051,7.09874 2.24793,8.91356L 2.24793,8.91356C 4.06381,10.7284 7.00578,10.7284 8.82271,8.91356L 8.82271,8.91356C 10.6375,7.09874 10.6375,4.15466 8.82271,2.33984L 8.82271,2.33984C 7.91424,1.43137 6.72478,0.977134 5.53427,0.977134L 5.53427,0.977134C 4.34481,0.977134 3.15535,1.43137 2.24793,2.33984 Z M 2.72013,8.44348C 1.16411,6.88746 1.16411,4.36593 2.72013,2.81097L 2.72013,2.81097C 4.27403,1.25601 6.79556,1.25601 8.35158,2.81097L 8.35158,2.81097C 9.90654,4.36593 9.90654,6.88746 8.35158,8.44348L 8.35158,8.44348C 7.57304,9.22096 6.55471,9.6097 5.53532,9.6097L 5.53532,9.6097C 4.51594,9.6097 3.49761,9.22096 2.72013,8.44348 Z ">
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="-0.0861956,-0.0861225"
                                                 EndPoint="2.15696,2.1571">
                                <GradientStop Color="#FFFFFFFF"
                                              Offset="0" />
                                <GradientStop Color="#FFFFFFFF"
                                              Offset="0.126373" />
                                <GradientStop Color="#FF57585A"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing Geometry="F1 M 9.9752,9.97837C 9.4692,10.4844 9.4692,11.303 9.9752,11.809L 13.157,14.9929C 13.663,15.4978 14.4827,15.4978 14.9887,14.9929L 14.9887,14.9929C 15.4947,14.4859 15.4947,13.6651 14.9887,13.1601L 11.8069,9.97837C 11.5545,9.72484 11.2228,9.59808 10.8911,9.59808L 10.8911,9.59808C 10.5594,9.59808 10.2277,9.72484 9.9752,9.97837 Z ">
                        <GeometryDrawing.Brush>
                            <LinearGradientBrush StartPoint="0.341201,0.658594"
                                                 EndPoint="0.789898,0.658594">
                                <LinearGradientBrush.RelativeTransform>
                                    <TransformGroup>
                                        <SkewTransform CenterX="0.341201"
                                                       CenterY="0.658594"
                                                       AngleX="0.0104477"
                                                       AngleY="0" />
                                        <RotateTransform CenterX="0.341201"
                                                         CenterY="0.658594"
                                                         Angle="-44.9948" />
                                    </TransformGroup>
                                </LinearGradientBrush.RelativeTransform>
                                <GradientStop Color="#FF85878A"
                                              Offset="0" />
                                <GradientStop Color="#FF85878A"
                                              Offset="0.0549469" />
                                <GradientStop Color="#FFECEDEE"
                                              Offset="0.752747" />
                                <GradientStop Color="#FFECEDEE"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                    </GeometryDrawing>
                    <GeometryDrawing Geometry="F1 M 14.9882,13.1601C 15.4942,13.6661 15.4942,14.4859 14.9882,14.9919C 14.4822,15.4978 13.6624,15.4978 13.1575,14.9919L 9.97467,11.809C 9.46868,11.303 9.46868,10.4844 9.97467,9.97837C 10.4807,9.47132 11.3015,9.47132 11.8064,9.97837L 14.9882,13.1601 Z ">
                        <GeometryDrawing.Pen>
                            <Pen Thickness="0.666667"
                                 LineJoin="Round"
                                 Brush="#FF7A7A7A" />
                        </GeometryDrawing.Pen>
                    </GeometryDrawing>
                </DrawingGroup>
            </DrawingBrush.Drawing>
        </DrawingBrush>

        <!-- Folder icon courtesy of http://www.iconarchive.com/show/hydropro-icons-by-media-design/HP-Blank-Folder-icon.html -->

        <ControlTemplate x:Key="LoadButtonTemplate"
                         TargetType="{x:Type Button}">
            <Grid x:Name="grid"
                  Width="16"
                  Height="16"
                  Opacity="0.5"
                  Visibility="Visible">
                <Image Height="16"
                       Width="16"
                       Source="folder.png" />
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsEnabled"
                         Value="True">
                    <Setter Property="Visibility"
                            TargetName="grid"
                            Value="Visible" />
                    <Setter Property="Opacity"
                            TargetName="grid"
                            Value="0.75" />
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsMouseOver"
                                   Value="True" />
                        <Condition Property="IsEnabled"
                                   Value="True" />
                    </MultiTrigger.Conditions>
                    <Setter Property="Opacity"
                            TargetName="grid"
                            Value="1" />
                    <Setter Property="Visibility"
                            TargetName="grid"
                            Value="Visible" />
                </MultiTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>


        
        <ControlTemplate x:Key="InspectButtonTemplate"
                         TargetType="{x:Type Button}">
            <Grid x:Name="grid"
                  Width="16"
                  Height="16"
                  Opacity="0.5"
                  Visibility="Visible"
                  Background="{DynamicResource Search}" />
            <ControlTemplate.Triggers>
                <Trigger Property="IsEnabled"
                         Value="True">
                    <Setter Property="Visibility"
                            TargetName="grid"
                            Value="Visible" />
                    <Setter Property="Opacity"
                            TargetName="grid"
                            Value="0.75" />
                </Trigger>
                <MultiTrigger>
                    <MultiTrigger.Conditions>
                        <Condition Property="IsMouseOver"
                                   Value="True" />
                        <Condition Property="IsEnabled"
                                   Value="True" />
                    </MultiTrigger.Conditions>
                    <Setter Property="Opacity"
                            TargetName="grid"
                            Value="1" />
                    <Setter Property="Visibility"
                            TargetName="grid"
                            Value="Visible" />
                </MultiTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
      
        

        <LinearGradientBrush x:Key="BorderGradient"
                             EndPoint="0.5,1"
                             StartPoint="0.5,0">
            <GradientStop Color="Black"
                          Offset="0" />
            <GradientStop Color="#FF002C76"
                          Offset="1" />
        </LinearGradientBrush>
        <ControlTemplate x:Key="ExitButtonTemplate"
                         TargetType="{x:Type Button}">
            <ControlTemplate.Resources>
                <Storyboard x:Key="OnMouseEnter1">
                    <ColorAnimationUsingKeyFrames BeginTime="00:00:00"
                                                  Storyboard.TargetName="path"
                                                  Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                        <SplineColorKeyFrame KeyTime="00:00:00"
                                             Value="#FF4C0000" />
                        <SplineColorKeyFrame KeyTime="00:00:00.2000000"
                                             Value="Red" />
                    </ColorAnimationUsingKeyFrames>
                </Storyboard>
                <Storyboard x:Key="OnMouseLeave1">
                    <ColorAnimationUsingKeyFrames BeginTime="00:00:00"
                                                  Storyboard.TargetName="path"
                                                  Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                        <SplineColorKeyFrame KeyTime="00:00:00"
                                             Value="Red" />
                        <SplineColorKeyFrame KeyTime="00:00:00.2000000"
                                             Value="#FF4C0000" />
                    </ColorAnimationUsingKeyFrames>
                </Storyboard>
            </ControlTemplate.Resources>
            <Grid HorizontalAlignment="Center"
                  VerticalAlignment="Center"
                  Background="#02FFFFFF">
                <Path x:Name="path"
                      Fill="#FF4E0000"
                      Stretch="Fill"
                      HorizontalAlignment="Center"
                      VerticalAlignment="Center"
                      Width="12.697"
                      Height="12.697"
                      RenderTransformOrigin="0.5,0.5"
                      Data="M3.3229167,3.3134766 L5.1637368,3.3134766 L9.6477861,7.7880869 L14.179036,3.3134766 L16.019857,3.3134766 L16.019857,5.1542978 L11.488606,9.6289072 L16.019857,14.112957 L16.019857,16.010418 L14.179036,16.010418 L9.6477861,11.479168 L5.1637368,16.010418 L3.3229167,16.010418 L3.3229167,14.169598 L7.7975259,9.6289072 L3.3229167,5.1542978 z">
                    <Path.RenderTransform>
                        <TransformGroup>
                            <ScaleTransform />
                            <SkewTransform />
                            <RotateTransform />
                            <TranslateTransform />
                        </TransformGroup>
                    </Path.RenderTransform>
                </Path>
            </Grid>
            <ControlTemplate.Triggers>
                <EventTrigger RoutedEvent="Mouse.MouseLeave">
                    <BeginStoryboard x:Name="OnMouseLeave1_BeginStoryboard"
                                     Storyboard="{StaticResource OnMouseLeave1}" />
                </EventTrigger>
                <EventTrigger RoutedEvent="Mouse.MouseEnter">
                    <BeginStoryboard Storyboard="{StaticResource OnMouseEnter1}" />
                </EventTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
        <ControlTemplate x:Key="RefreshButtonTemplate"
                         TargetType="{x:Type Button}">
            <ControlTemplate.Resources>
                <Storyboard x:Key="OnMouseEnter1">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                   Storyboard.TargetName="image"
                                                   Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00.3000000"
                                              Value="1" />
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
                <Storyboard x:Key="OnMouseLeave1">
                    <DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
                                                   Storyboard.TargetName="image"
                                                   Storyboard.TargetProperty="(UIElement.Opacity)">
                        <SplineDoubleKeyFrame KeyTime="00:00:00"
                                              Value="1" />
                        <SplineDoubleKeyFrame KeyTime="00:00:00.3000000"
                                              Value="0.7" />
                    </DoubleAnimationUsingKeyFrames>
                </Storyboard>
            </ControlTemplate.Resources>
            <Grid>
                <Image x:Name="image"
                       Margin="0"
                       Source="refresh.png"
                       Stretch="Uniform"
                       Width="20"
                       Height="20"
                       Opacity="0.7" />
            </Grid>
            <ControlTemplate.Triggers>
                <EventTrigger RoutedEvent="Mouse.MouseLeave">
                    <BeginStoryboard x:Name="OnMouseLeave1_BeginStoryboard"
                                     Storyboard="{StaticResource OnMouseLeave1}" />
                </EventTrigger>
                <EventTrigger RoutedEvent="Mouse.MouseEnter">
                    <BeginStoryboard Storyboard="{StaticResource OnMouseEnter1}" />
                </EventTrigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Window.Resources>


    <Border CornerRadius="3"
            BorderThickness="1"
            Background="{DynamicResource BlueGlassGradient}"
            BorderBrush="{DynamicResource BorderGradient}">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="22"/>
                <ColumnDefinition Width="22"/>
                <ColumnDefinition Width="22"/>
            </Grid.ColumnDefinitions>
            <TextBox Margin="2"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Center"
                     x:Name="txtAddress" />
            <ProgressBar Margin="2"
                         HorizontalAlignment="Stretch"
                         Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=InjectProgress}"
                         Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=ProgressVisibility}"
                         Maximum="100"
                         Minimum="0" />
                         
            <Button Grid.Column="1"
                    Margin="4,1"
                    Template="{DynamicResource LoadButtonTemplate}"
                    ToolTip="Open XAP from disk..."
                    Command="{x:Static si:MainWindow.LoadCommand}" />
            <Button Grid.Row="2"
                    Margin="4,1"
                    Grid.Column="2"
                    ToolTip="Inject!"
                    Command="{x:Static si:MainWindow.InspectCommand}"
                    Template="{DynamicResource InspectButtonTemplate}" />
            <Button ToolTip="Exit"
                    Margin="4,1"
                    Grid.Column="3"
                    Command="{x:Static si:MainWindow.ExitCommand}"
                    Template="{DynamicResource ExitButtonTemplate}" />
        </Grid>

    </Border>
</Window>
